#include "mainwindow.h"
#include <QFileDialog>
#include <QStandardItemModel>
#include "./ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow) {
    ui->setupUi(this);

    // table
    auto *model = new QStandardItemModel(ui->tab_fileList);
    model->setRowCount(1);
    model->setColumnCount(2);
    model->setHeaderData(0, Qt::Horizontal, "文件名");
    model->setHeaderData(1, Qt::Horizontal, "状态");
    ui->tab_fileList->setModel(model);
    ui->tab_fileList->setEditTriggers(QAbstractItemView::NoEditTriggers);
    ui->tab_fileList->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
    ui->tab_fileList->horizontalHeader()->resizeSection(1, 100);
}

MainWindow::~MainWindow() {
    delete ui;
}

void MainWindow::on_btn_selectDownloadDir_clicked() {
    const QString downloadDir = QFileDialog::getExistingDirectory(this);
    if (!downloadDir.isEmpty()) {
        this->ui->lab_downloadDir->setText(downloadDir);
        this->scan_.scanVideoFiles(downloadDir);
    }
}
